package cc.geguo.time;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 作者  Administrator
 * 时间  2017/3/15 19:08
 * 文件  AjaxDemo40
 * 描述
 */
@WebServlet(name = "AjaxTimeServlet2",urlPatterns = "/time2")
public class AjaxTimeServlet2 extends HttpServlet {

	public AjaxTimeServlet2() {
		System.out.println("实例化.........");
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		String nowStrr = dateFormat.format(new Date());
		response.setContentType("text/html;charset=utf-8");
		PrintWriter writer = response.getWriter();
		writer.write(nowStrr);
		writer.flush();
		writer.close();
	}
}
